home *** CD-ROM | disk | FTP | other *** search
/ Mastering Public Speaking / Mastering Public Speaking.iso / pc / Click Here.exe / Click Here.dxr / Internal_3_Rollover Cursor Change.ls < prev    next >
Encoding:
Text File  |  2003-05-13  |  5.5 KB  |  142 lines

  1. property spriteNum, myCursorType, myBuiltInCursor, myCursorMember, myCustomCursor, myCustomMask, mySprite, mySavedCursor
  2.  
  3. on getBehaviorDescription me
  4.   return "ROLLOVER CURSOR CHANGE" & RETURN & RETURN & "Changes the cursor when the mouse rolls over the current sprite. " & "Choose one of the pointers included with Director, or specify two 1-bit 16x16 pixel bitmap members: one to act as the pointer image, the other to define the transparent/opaque areas of the cursor." & RETURN & RETURN & "TIPS:" & RETURN & "Place a single pixel at the topRight and bottomLeft of the image itself to create what is in fact a 17x17 pixel bitmap. " & "These extra pixels will not appear in the cursor (they will be clipped) but the mask will align with them. " & "This ensures that the opaque area surrounds the cursor image correctly." & RETURN & RETURN & "Set the regPoint of the image to define the cursor's hotspot." & RETURN & RETURN & "PARAMETERS:" & RETURN & "* EITHER - Use one of Director's built-in cursors." & RETURN & RETURN & "* OR - Use your own bitmap images." & RETURN & "* Custom Image " & RETURN & "* Custom Mask" & RETURN & RETURN & "To use custom images, ensure that " & QUOTE & "1 bit bitmap" & QUOTE & " is selected as the type of cursor."
  5. end
  6.  
  7. on getBehaviorTooltip me
  8.   return "Use with graphic members." & RETURN & RETURN & "Modifies the cursor when the mouse rolls over a sprite." & RETURN & RETURN & "You can use built-in or custom images for the cursor."
  9. end
  10.  
  11. on beginSprite me
  12.   SetSpriteCursor(me)
  13. end
  14.  
  15. on endSprite me
  16.   mySprite.cursor = mySavedCursor
  17. end
  18.  
  19. on SetSpriteCursor me
  20.   mySprite = sprite(me.spriteNum)
  21.   mySavedCursor = mySprite.cursor
  22.   if voidp(myCursorType) then
  23.     mySprite.cursor = myBuiltInCursor
  24.     exit
  25.   end if
  26.   case myCursorType of
  27.     "Built-in cursor":
  28.       mySprite.cursor = myBuiltInCursor
  29.     "Cursor Member":
  30.       myCursorMember = value(myCursorMember)
  31.       cursorList = [myCursorMember.number]
  32.       mySprite.cursor = cursorList
  33.     "1 bit bitmap":
  34.       myCustomCursor = value(myCustomCursor)
  35.       cursorList = [myCustomCursor.number]
  36.       if myCustomMask <> "no mask" then
  37.         myCustomMask = value(myCustomMask)
  38.         cursorList.append(myCustomMask.number)
  39.       end if
  40.       mySprite.cursor = cursorList
  41.   end case
  42. end
  43.  
  44. on isOKToAttach me, aSpriteType, aSpriteNum
  45.   case aSpriteType of
  46.     #graphic:
  47.       return 1
  48.     #script:
  49.       return 0
  50.   end case
  51. end
  52.  
  53. on getPropertyDescriptionList me
  54.   if not (the currentSpriteNum) then
  55.     exit
  56.   end if
  57.   propertyDescriptionList = [:]
  58.   cursorTypes = []
  59.   cursorMembersList = GetCursorMembers(me)
  60.   cursorBitmapsList = GetCursorBitmaps(me)
  61.   cursorMasksList = duplicate(cursorBitmapsList)
  62.   cursorMasksList.addAt(1, "no mask")
  63.   cursorMembers = cursorMembersList.count()
  64.   bitmapCursors = cursorBitmapsList.count()
  65.   if cursorMembers then
  66.     cursorTypes.append("Cursor Member")
  67.   end if
  68.   if bitmapCursors then
  69.     cursorTypes.append("1 bit bitmap")
  70.   end if
  71.   if cursorTypes.count() then
  72.     cursorTypes.addAt(1, "Built-in cursor")
  73.     propertyDescriptionList.addProp(#myCursorType, [#comment: "CHOICE OF TYPE - Use which type of cursor?", #format: #string, #range: cursorTypes, #default: cursorTypes[1]])
  74.     propertyDescriptionList.addProp(#myBuiltInCursor, [#comment: "CHOICE OF CURSOR   -               Built-in cursor:", #format: #cursor, #default: 280])
  75.   else
  76.     return [#myBuiltInCursor: [#comment: "Use which cursor?", #format: #cursor, #default: 280]]
  77.   end if
  78.   if cursorMembers then
  79.     propertyDescriptionList.addProp(#myCursorMember, [#comment: "-             Cursor member:", #format: #member, #range: cursorMembersList, #default: cursorMembersList[1]])
  80.   end if
  81.   if bitmapCursors then
  82.     propertyDescriptionList.addProp(#myCustomCursor, [#comment: "-   1 bit bitmap (image)", #format: #bitmap, #range: cursorBitmapsList, #default: cursorBitmapsList[1]])
  83.     propertyDescriptionList.addProp(#myCustomMask, [#comment: "1 bit bitmap   (mask)", #format: #bitmap, #range: cursorMasksList, #default: cursorMasksList[1]])
  84.   end if
  85.   return propertyDescriptionList
  86. end
  87.  
  88. on GetCursorMembers me
  89.   cursorMembersList = []
  90.   maxCastLib = the number of castLibs
  91.   theCastLib = 1
  92.   repeat while theCastLib <= maxCastLib
  93.     maxMember = the number of castMembers of castLib theCastLib
  94.     memberNumber = 1
  95.     repeat while memberNumber <= maxMember
  96.       theMember = member(memberNumber, theCastLib)
  97.       if theMember.type = #cursor then
  98.         if theMember.name = EMPTY then
  99.           cursorMembersList.append(theMember)
  100.         else
  101.           cursorMembersList.append(theMember.name)
  102.         end if
  103.       end if
  104.       memberNumber = 1 + memberNumber
  105.     end repeat
  106.     theCastLib = 1 + theCastLib
  107.   end repeat
  108.   return cursorMembersList
  109. end
  110.  
  111. on GetCursorBitmaps me
  112.   cursorBitmapsList = []
  113.   maxCastLib = the number of castLibs
  114.   theCastLib = 1
  115.   repeat while theCastLib <= maxCastLib
  116.     maxMember = the number of castMembers of castLib theCastLib
  117.     memberNumber = 1
  118.     repeat while memberNumber <= maxMember
  119.       theMember = member(memberNumber, theCastLib)
  120.       if theMember.type = #bitmap then
  121.         if theMember.depth > 1 then
  122.         else
  123.           if theMember.width > 20 then
  124.           else
  125.             if theMember.height > 20 then
  126.             else
  127.               if theMember.name = EMPTY then
  128.                 cursorBitmapsList.append(theMember)
  129.               else
  130.                 cursorBitmapsList.append(theMember.name)
  131.               end if
  132.             end if
  133.           end if
  134.         end if
  135.       end if
  136.       memberNumber = 1 + memberNumber
  137.     end repeat
  138.     theCastLib = 1 + theCastLib
  139.   end repeat
  140.   return cursorBitmapsList
  141. end
  142.